package org.jeecg.modules.engineering.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.engineering.entity.*;
import org.jeecg.modules.engineering.mapper.*;
import org.jeecg.modules.engineering.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.*;


/**
 * @Description: 设备采集信息表
 * @Author: jeecg-boot
 * @Date:   2019-08-20
 * @Version: V1.0
 */
@Service
public class EquipCollectInfoServiceImpl extends ServiceImpl<EquipCollectInfoMapper, EquipCollectInfo> implements IEquipCollectInfoService {


    @Autowired
    private EquipCollectInfoMapper equipCollectInfoMapper;

    @Override
    @Transactional
    public void insertBatch(List<EquipCollectInfo> list,String equipId) {
        //equipCollectInfoMapper.deleteByEquipIds(Collections.singletonList(equipId));
        String nowDateString = DateUtils.date2Str(new Date(),new SimpleDateFormat("yyyyMM"));
        equipCollectInfoMapper.insertBatch("",list);
        equipCollectInfoMapper.insertBatch(nowDateString,list);
    }

    @Override
    public IPage<EquipCollectInfo> selectSqlList(Page<EquipCollectInfo> page, String itemId, String equipName, List<String> projectIds) {
        return page.setRecords(equipCollectInfoMapper.selectSqlList(page,itemId,equipName,projectIds));
    }

    @Override
    public List<EquipCollectInfo> selectSqlList(String itemId, String equipName, List<String> projectIds) {
        return equipCollectInfoMapper.selectSqlList(itemId,equipName,projectIds);
    }

}
